//
//  B_RenCell.m
//  Estate
//
//  Created by heyong on 16/6/8.
//  Copyright © 2016年 ttsx. All rights reserved.
//

#import "B_RenCell.h"

@implementation B_RenCell

- (void)setIsEdit:(BOOL)isEdit{
    if(isEdit){
        self.num.userInteractionEnabled=YES;
    }else{
        self.num.userInteractionEnabled=NO;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle=UITableViewCellSelectionStyleNone;
    self.num.delegate=self;
    self.title.textColor=UIColorFromRGB(0x797979);
    self.num.textColor=UIColorFromRGB(0x797979);
    self.ren.textColor=UIColorFromRGB(0x797979);
}
//设置分割线
- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor); CGContextFillRect(context, rect);
    //    //上分割线，
    //    CGContextSetStrokeColorWithColor(context, [UIColor grayColor].CGColor); CGContextStrokeRect(context, CGRectMake(0, -1, rect.size.width , 1));
    //下分割线
    CGContextSetStrokeColorWithColor(context,[UIColor colorWithRed:0.89 green:0.89 blue:0.90 alpha:1.00].CGColor); CGContextStrokeRect(context, CGRectMake(0, rect.size.height, rect.size.width, 1));
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (IBAction)numChange:(UITextField *)sender {
    if(self.renBlock){
        self.renBlock(sender.text);
    }
}

- (void)configWithPlaceholder:(NSString *)phStr andValue:(NSString *)valueStr andLabel:(NSString*)label andKeyType:(UIKeyboardType) kt{
    self.title.text=label;
    self.num.placeholder=phStr;
    self.num.text=valueStr;
    self.num.keyboardType=kt;
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    //   限制苹果系统输入法  禁止输入表情
    if ([[[UITextInputMode currentInputMode]primaryLanguage] isEqualToString:@"emoji"]) {
        return NO;
    }
 
    return YES;

}

#pragma mark UITextFieldDelegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [_num resignFirstResponder];
    
    return  YES;
}

@end
